package com.roadjava.convert.demo04;

import com.roadjava.beans.dto.CarDTO;
import com.roadjava.beans.vo.VehicleVO;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public abstract class CarConvert04 {

    public static CarConvert04 INSTANCE = Mappers.getMapper(CarConvert04.class);

    /**
     * BeanMapping：忽略mapstruct的默认映射行为。避免不需要的赋值、避免属性覆盖
     */
//    @Mapping(source = "price", target = "price", ignore = true)
    @BeanMapping(ignoreByDefault = true)
    @Mapping(source = "id", target = "id")
    @Mapping(source = "brand", target = "brandName")
    public abstract VehicleVO carDTO2vehicleVO(CarDTO carDTO);

}